package com.woniuxy.controller;

import com.woniuxy.entity.ExamResult;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.impl.StudentExamServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author:deng
 * @time:2022/5/5 18:50
 * @描述：学生答题界面Controller
 */
@Api(tags="学生答卷")
@RestController
public class StudentExamController {

    @Autowired
    StudentExamServiceImpl studentExamServiceImpl;
    /*根据试卷id查询对应的题*/
    @ApiOperation("根据试卷id查询对应的题")
    @GetMapping("paper/{paperId}")
    public Map<Integer, List<?>> findTopticByPid(@PathVariable Integer paperId){
        return studentExamServiceImpl.findTopticByPid(paperId);
    }
    @ApiOperation("回答答案存入数据库")
    @PostMapping("score")
    public ResponseEntity setAnswerScore(@RequestBody ExamResult examResult){

        System.out.println(examResult);
        return studentExamServiceImpl.setAnswerScore(examResult);
    }

}
